﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Microsoft.WindowsAPICodePack.Shell;
namespace NASM_Develop_IDE
{
    public partial class IDEPreferencesData : GlassForm
    {
        
        private Solution solution;
        private StringBuilder output;
        public IDEPreferencesData(Solution solution)
        {
            output = new StringBuilder();
            if (solution == null)
            {
                throw new ArgumentNullException("Argument 'solution' Is Not Pointing To A Valid Object!");
            }
            this.solution = solution;
            InitializeComponent();
            TextBoxHighlighter.Highlight(binaryOutput, "Enter Output Name (e.g. google.COM)");
            AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(BuildDialog_AeroGlassCompositionChanged);
            if (AeroGlassCompositionEnabled)
            {
                ExcludeControlFromAeroGlass(panel);
            }
            else
            {
                BackColor = Color.Aqua;
            }
            
        }



        void BuildDialog_AeroGlassCompositionChanged(object sender, AeroGlassCompositionChangedEventArgs e)
        {
            if (e.GlassAvailable)
            {
                
                ExcludeControlFromAeroGlass(panel);
                Invalidate();
            }
            else
            {
               
                this.BackColor = Color.Aqua;
            }
        }

        public StringBuilder Output
        {
            get
            {
                return output;
            }
        }

        private void buildButton_Click(object sender, EventArgs e)
        {
            NASMBuilder.Clean(solution.AbsolutePathOfBinFolder);
            solution.NameOfOutputBinary = binaryOutput.Text;
            string sources = "";
            
            foreach (string source in solution.AbsolutePathOfSources)
                sources += (source + " ");


            NASMBuilder.Compile("-f bin \"" + sources.Remove(sources.Length - 1) + "\" -o \"" + solution.AbsolutePathOfBinFolder + "\\" + binaryOutput.Text + "\"" , out output);
        }
    }
}
